<template>
    <div>
        <div class="wei-body">
            <div class="header-contain">
                <!-- title -->
                <div class="p0">
                    <div class="p1"></div>
                    <div class="p2">
                        <img src="/static/images/health.png" alt="">
                        <label>健康食材 餐餐都香</label>
                        <img class="img" src="/static/images/health.png" alt="">
                    </div>
                    <div class="p3"></div>
                </div>
                <!-- 专区 -->
                <div class="body-header">
                    <div @click="showFreshDish" class="tab1">
                        <img src="/static/images/fired-dish.jpg" alt="">
                        <p>新鲜炒菜</p>
                        </div>
                    <div @click="showNoodle" class="tab2">
                        <img src="/static/images/noodles.jpg" alt="">
                        <p>粉面专区</p>
                    </div>
                    <div @click="showDessert" class="tab3">
                        <img src="/static/images/dessert.jpg" alt="">
                        <p>烘焙美食</p>
                    </div>
                </div>
                <div class="sup-cheap">
                    <div @click="showDetail" class="cheap">
                        <div class="cheap-title">
                            <p class="c-p">限时</p>
                            <p class="c-p">促销</p>
                            <div class="c-p1">点我抢购</div>
                        </div>
                        <div class="cheap-text" v-for="(item, index) in TimeLimitList" :key="index">
                            <img :src="item.dish_images" alt="">
                            <label>
                                <p class="t1">{{ item.dish_name }}</p>
                                <p class="t4">上午：{{ cheapTime1 }}</p>
                                <p class="t4">下午：{{ cheapTime2 }}</p>
                                <div class="pr1">促销价</div>
                                <span class="pr2">{{ item.dish_nprice / 100 }}</span>
                                <span class="pr2-1">元</span>
                                <span class="pr3">{{ item.dish_gprice / 100 }}元</span>
                            </label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="body-contain">
                <div class="child1">
                    <div class="child1-t1">餐餐推荐</div>
                    <scroll-view class="recommend_scroll_x_box" scroll-x="true">
                        <view  @click="showDetail" class="recommend_hot_box" v-for="(item, index) in recommend" :key="index">
                            <img :src="item.dish_images" class="recommend_hot_image" />
                            <div class="recommend-title">
                                <p>{{ item.dish_name }}</p>
                                <div class="recommend-title-child">
                                    <div class="recommend-d">
                                        <label>￥</label>
                                        <label class="recommend-num"> {{ item.dish_nprice / 100 }}</label>
                                        <div class="recommend-add">
                                            <p v-if="item.dish_gprice.length > 0">￥ {{ item.dish_gprice / 100 }}</p>
                                        </div>
                                    </div>
                                    <div @click.stop="getDish" class="recommend-img">
                                        <img src="/static/images/add.png" alt="">
                                    </div>
                                </div>
                            </div>
                        </view>
                    </scroll-view>
                </div>
                
                <div class="child2">
                    <div class="child2-t1">
                        <div class="t1-left">
                            <p class="child2-p1">新鲜食材</p>
                            <p class="child2-p2">健康生活 餐餐新鲜</p>
                            <div class="child2-p3">立即抢购</div>
                        </div>
                        <div class="t1-right">
                            <img :src="freshFood" alt="">
                        </div>
                    </div>
                    <div class="child2-con">
                        <div @click="showDetail" class="con-div" v-for="(item, index) in fresh" :key="index">
                            <div class="re-xiao"><p>热销</p></div>
                            <img :src="item.dish_images" alt="">
                            <div class="recommend-title">
                                <p class="con-p">{{ item.dish_name }}</p>
                                <div class="recommend-title-child">
                                    <div>
                                        <label>￥</label>
                                    <label class="recommend-num"> {{ item.dish_nprice / 100 }}</label>
                                    <div class="recommend-add">
                                        <p v-if="item.dish_gprice.length > 0">￥ {{ item.dish_gprice / 100 }}</p>
                                    </div>
                                    </div>
                                    <div @click.stop="getDish" class="recommend-img">
                                        <img src="/static/images/add.png" alt="">
                                    </div>
                                </div>
                                
                            </div>
                        </div>
                        <div @click="showFreshDish" class="con-div1"><p>查看更多</p></div>
                    </div>
                </div>

                <div class="child3">
                    <div class="child2-t2">
                        <div class="t1-left">
                            <p class="child2-p1 child2-colo">小吃专栏</p>
                            <p class="child2-p2 child2-colo">美味无限 数量有限</p>
                            <div class="child2-p3 child2-colo">立即抢购</div>
                        </div>
                        <div class="t1-right">
                            <img :src="snackImg" alt="">
                        </div>
                    </div>
                    <div class="child2-con">
                        <div @click="showDetail" class="con-div" v-for="(item, index) in snack" :key="index">
                            <div class="re-xiao1"><p>爆款</p></div>
                            <img :src="item.dish_images" alt="">
                            <div class="recommend-title">
                                    <p class="con-p">{{ item.dish_name }}</p>
                                    <div class="recommend-title-child">
                                        <div>
                                            <label>￥</label>
                                        <label class="recommend-num"> {{ item.dish_nprice / 100 }}</label>
                                        <div class="recommend-add">
                                            <p v-if="item.dish_gprice.length > 0">￥ {{ item.dish_gprice / 100 }}</p>
                                        </div>
                                        </div>
                                        <div @click.stop="getDish" class="recommend-img">
                                            <img src="/static/images/add.png" alt="">
                                        </div>
                                        
                                    </div>
                                </div>
                        </div>
                        <div @click="showDessert" class="con-div1"><p>查看更多</p></div>
                    </div>
                </div>

                <div class="child3">
                    <div class="child2-t3">
                        <div class="t1-left">
                            <p class="child2-p1 child3-colo">粉面特惠</p>
                            <p class="child2-p2 child3-colo">面贵于品 情聚于堂</p>
                            <div class="child2-p3 child2-colo">立即购买</div>
                        </div>
                        <div class="t1-right">
                            <img :src="noodleImg" alt="">
                            </div>
                    </div>
                    <div class="child2-con">
                        <div @click="showDetail" class="con-div" v-for="(item, index) in flour" :key="index">
                            <div class="re-xiao1"><p>推荐</p></div>
                            <img :src="item.dish_images" alt="">
                            <div class="recommend-title">
                                    <p class="con-p">{{ item.dish_name }}</p>
                                    <div class="recommend-title-child">
                                        <div>
                                            <label>￥</label>
                                            <label class="recommend-num"> {{ item.dish_nprice / 100 }}</label>
                                            <div class="recommend-add">
                                                <p v-if="item.dish_gprice.length > 0">￥ {{ item.dish_gprice / 100 }}</p>
                                            </div>
                                        </div>
                                        <div @click.stop="getDish" class="recommend-img">
                                            <img src="/static/images/add.png" alt="">
                                        </div>
                                    </div>
                                </div>
                        </div>
                        <div @click="showNoodle" class="con-div1"><p>查看更多</p></div>
                    </div>
                </div>
                <div class="contain-footer"><p>客官别再划啦 下面什么都没有了 T_T</p></div>
            </div>
        </div>
    </div>
</template>

<script>
import { GET } from '../utils/base'
export default {
    data() {
        return {
            recommend_count: 7,
            fresh_count: 9,
            snack_count: 6,
            flour_count: 6,
            recommend: [],
            fresh: [],
            snack: [],
            flour: [],
            TimeLimitList: [],
            cheapTime1: '11:30-13:30',
            cheapTime2: '16:30-18:30',
            freshFood: '/static/images/fresh-food.jpg',
            snackImg: '/static/images/snack.jpg',
            noodleImg: '/static/images/未标题-2.jpg',
        }
    },
    methods: {
        showFreshDish() {
            wx.navigateTo({
            url: '/pages/freshDish/main'
            })
        },
        showNoodle() {
            wx.navigateTo({
            url: '/pages/noodle/main'
            })
        },
        showDessert() {
            wx.navigateTo({
            url: '/pages/dessert/main'
            })
        },
        showDetail () {
            wx.navigateTo({
            url: '/pages/detail/main'
            })
        },

        // 加购物车
        getDish() {
            console.log(111);
            
        },

        // 获取主题
        getTimeLimitList() {
            try {
                this.$httpWx.GET({
                url: 'getTimeLimitList',
                }).then(res => {
                    this.TimeLimitList = res.data
                })
            } catch (e) {
                showModel('请求失败', '请检查网络后再试!')
            }
        },

        // 获取餐餐推荐列表
        getRecommend() {
            try {
                this.$httpWx.GET({
                url: 'getRecommendList/' + this.recommend_count,
                }).then(res => {
                    this.recommend = res.data
                })
            } catch (e) {
                showModel('请求失败', '请检查网络后再试!')
            }
        },

        // 获取新鲜食材列表
        getFreshList() {
            try {
                this.$httpWx.GET({
                url: 'getFreshList/' + this.fresh_count,
                }).then(res => {
                    this.fresh = res.data
                })
            } catch (e) {
                showModel('请求失败', '请检查网络后再试!')
            }
        },

        // 获取小吃专栏列表
        getSnackList() {
            try {
                this.$httpWx.GET({
                url: 'getSnackList/' + this.snack_count,
                }).then(res => {
                    this.snack = res.data
                })
            } catch (e) {
                showModel('请求失败', '请检查网络后再试!')
            }
        },

        // 获取粉面特惠列表
        getFlourList() {
            try {
                this.$httpWx.GET({
                url: 'getFlourList/' + this.flour_count,
                }).then(res => {
                    this.flour = res.data
                })
            } catch (e) {
                showModel('请求失败', '请检查网络后再试!')
            }
        }
    },
    
    onLoad() {
        this.getTimeLimitList();
        this.getRecommend()
        this.getFreshList()
        this.getSnackList()
        this.getFlourList()
    }
}
</script>

<style scoped>
.wei-body {
  width: 100%;
}

.header-contain {
    height: 300px;
    width: 100%;
}
.wei-body .p0 {
    display: flex;
    width: 100%;
}
.p1 {
    width: 29%;
    height: 2px;
    border-top: 1px solid rgb(121, 117, 117);
    margin-top: 15px;
    margin-left: 10px;
}
.p2 {
    width: 39%;
    padding-left: 3px;
    font-size: 12px;
    color: rgb(121, 117, 117);
    margin-top: 5px;
}
.p2 label {
    position:absolute;
    padding-top: 3px;
    text-align: center;
}
.p2 img {
    width: 20px;
    height: 20px;
}
.p2 .img {
    float: right;
    padding-right: 3px;
}
.p3 {
    width: 29%;
    height: 2px;
    border-top: 1px solid rgb(121, 117, 117);
    margin-top: 15px;
    margin-right: 10px;
}

.body-header {
    width: 100%;
    height: 100px;
    line-height: 20px;
    color: #111010;
    font-size: 17px;
    font-weight:inherit;
    display: flex;
    padding: 10px 10px 0 10px;
}
.body-header img {
    width: 100px;
    height: 65px;
    border-radius: 50%;
}
.body-header p {
    text-align: center;
    font-size: 15px;
}
.body-header .tab1 {
    width: 30%;
    margin-right: 15px;
    text-align: center;
}
.body-header .tab2 {
    width: 30%;
    margin-right: 15px;
}
.body-header .tab3 {
    width: 30%;
}

.sup-cheap {
    width: 100%;
    margin-top: 5px;
}
.sup-cheap .cheap {
    height: 145px;
    color: #111010;
    font-weight:inherit;
    display: flex;
    margin: 0 10px 0 10px;
    border-radius: 10px;
    padding-top: 1px;
    background: -webkit-linear-gradient(#d8f8d6,#a7f8a1);
    background: -o-linear-gradient(#d8f8d6,#a7f8a1);
    background: -moz-linear-gradient(#d8f8d6,#a7f8a1);
    background:linear-gradient(#d8f8d6,#a7f8a1);
}
.cheap .cheap-title {
    width: 18%;
    margin: 20px 0 0 15px;
}
.cheap .cheap-title .c-p {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 10px;
    line-height: 25px;
}
.cheap .cheap-title .c-p1 {
    width: 60px;
    height: 18px;
    font-size: 10px;
    margin-top: 25px;
    background: rgb(15, 206, 47);
    letter-spacing: 1px;
    border-radius: 10px;
    text-align: center;
    padding-top: 4px;
    color: #ffffff;
}
.cheap .cheap-text {
    width: 80%;
    background: #ffffff;
    margin: 10px 10px;
    border-radius: 5px;
    display: flex;
}
.cheap .cheap-text img {
    width: 50%;
    width: 110px;
    height: 75px;
    z-index: 10;
    padding: 25px 10px;
}
.cheap-text label {
    padding-top: 5px;
    padding-left: 5px;
}
.cheap .cheap-text .t1 {
    font-weight: 600;
    font-size: 15px;
    padding-top: 5px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    width: 120px;
}
.cheap .cheap-text .t2 {
    font-size: 10px;
    color: #867d7d;
}
.cheap .cheap-text .t3 {
    padding-top: 3px;
    font-size: 14px;
    color: #867d7d;
}
.cheap .cheap-text .t4 {
    padding-top: 5px;
    font-size: 12px;
    color: #867d7d;
    line-height: 12px;
}
.cheap-text .pr1 {
    width: 40px;
    height: 14px;
    background: -webkit-linear-gradient(rgb(248, 122, 49),rgb(250, 38, 23));
    background: -o-linear-gradient(rgb(248, 122, 49),rgb(250, 38, 23));
    background: -moz-linear-gradient(rgb(248, 122, 49),rgb(250, 38, 23));
    background:linear-gradient(rgb(248, 122, 49),rgb(250, 38, 23));
    font-size: 10px;
    color: #ffffff;
    font-weight: 400;
    text-align: center;
    border-radius: 4px;
    margin-top: 15px;
    letter-spacing: 2px;
}
.cheap-text .pr2 {
    font-size: 20px;
    color:rgb(250, 38, 23);
    font-weight: 800
}
.cheap-text .pr2-1 {
    font-size: 14px;
    color:rgb(250, 38, 23);
    font-weight: 600
}
.cheap-text .pr3 {
    font-size: 14px;
    color:rgb(110, 105, 104);
    font-weight: 400;
    text-decoration: line-through;
    margin-left: 10px;
}


.body-contain {
    background: rgb(241, 239, 239);
    width: 100%;
    padding-top: 1px;
    padding-bottom: 10px;
}
.body-contain .child1 {
    height: 195px;
    background: #ffffff;
    margin: 10px 10px 0 10px;
    border-radius: 10px;
}
.child1 .child1-t1 {
    font-size: 15px;
    font-weight: 500;
    padding: 5px 0 0 10px;
    letter-spacing: 3px;
}
.child1 .recommend_scroll_x_box {
  height: 165px;
  white-space: nowrap;
  display: flex;
}

/* 隐藏滚动条 */
::-webkit-scrollbar {
  width: 0;
  height: 0;
  color: transparent;
}

.recommend_hot_box {
  width: 110px;
  height: 165px;
  margin: 10px 5px 0 10px;
  display: inline-block;
}

.recommend_hot_image {
  width: 110px;
  height: 75px;
}
.recommend_hot_box .recommend-title p {
    font-size: 14px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    width: 110px;
}
.recommend-title .recommend-title-child {
    font-size: 12px;
    font-weight: 600;
    margin-top: 14px;
    color: rgb(250, 38, 23);
    display: flex;
}
.recommend-d {
    width: 50%;
}
.recommend-title-child .recommend-num {
    font-size: 18px;
    letter-spacing: 1px;
}
.recommend-add {
    font-size: 13px;
    color:rgb(110, 105, 104);
    font-weight: 500;
    text-decoration: line-through;
}
.recommend-title .recommend-img {
    width: 25px;
    height: 25px;
    margin-left: auto;
}
.recommend-title .recommend-img img {
    width: 100%;
    height: 100%;
}

.body-contain .child2 {
    background: #ffffff;
    margin: 10px 10px 0 10px;
    border-radius: 10px;
    padding-top: 0;
}
.child2-t1 {
    height: 115px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    display: flex;
    background: -webkit-linear-gradient(rgb(160, 250, 195),rgb(18, 221, 96));
    background: -o-linear-gradient(rgb(160, 250, 195),rgb(18, 221, 96));
    background: -moz-linear-gradient(rgb(160, 250, 195),rgb(18, 221, 96));
    background:linear-gradient(rgb(160, 250, 195),rgb(18, 221, 96));
}
.t1-left {
    width: 50%;
    margin: 10px 0 0 20px;
}
.child2-p1 {
    font-size: 25px;
    font-weight: 500;
    letter-spacing: 2px;
    color: #fdfdfd;
}
.child2-p2 {
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 2px;
    color: #fdfdfd;
}
.child2-p3 {
    width: 60px;
    height: 18px;
    font-size: 11px;
    margin-top: 15px;
    background: #ffffff;
    letter-spacing: 1px;
    border-radius: 10px;
    text-align: center;
    padding-top: 4px;
    color: rgb(18, 221, 96);
}
.t1-right {
    width: 50%;
    margin-top: 15px;
}
.t1-right img {
    width: 150px;
    height: 90px;
    border-radius: 5px;
}

.child2-con {
    display: flex;
    justify-content: left;
    flex-wrap: wrap;
    align-items: center;
}
.child2-con .con-div {
    width: 108px;
    height: 160px;
    margin: 10px 0 0 8px;
}
.con-div .re-xiao {
    position: absolute;
    width: 20px;
    height: 35px;
    background: rgb(253, 81, 13);
    font-size: 12px;
    text-align: center;
    color: #ffffff;
    border-bottom-right-radius: 30px;
    border-bottom-left-radius: 30px;
    letter-spacing: 1px;
    opacity: 0.8;
}
.child2-con img {
    width: 108px;
    height: 73px;
}
.recommend-title .con-p {
    font-size: 14px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    width: 110px;
}

.con-div1 {
    width: 100%;
    padding-bottom: 5px;
}
.child2-con .con-div1 p {
    width: 60px;
    font-size: 14px;
    color: gray;
    margin: 0 auto;
}

.child3 {
    background: #ffffff;
    margin: 10px 10px 0 10px;
    border-radius: 10px;
    padding-top: 0;
}
.child2-t2 {
    height: 115px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    display: flex;
    background: -webkit-linear-gradient(rgb(247, 239, 198),rgb(226, 202, 83));
    background: -o-linear-gradient(rgb(247, 239, 198),rgb(226, 202, 83));
    background: -moz-linear-gradient(rgb(247, 239, 198),rgb(226, 202, 83));
    background:linear-gradient(rgb(247, 239, 198),rgb(226, 202, 83));
}
.child2-t3 {
    height: 115px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    display: flex;
    background: -webkit-linear-gradient(rgb(236, 154, 140),rgb(199, 49, 22));
    background: -o-linear-gradient(rgb(236, 154, 140),rgb(199, 49, 22));
    background: -moz-linear-gradient(rgb(236, 154, 140),rgb(199, 49, 22));
    background:linear-gradient(rgb(236, 154, 140),rgb(199, 49, 22));
}
.child2-colo {
    color: rgb(250, 85, 19);
}
.child3-colo {
    color: rgb(245, 236, 233);
}
.con-div .re-xiao1 {
    position: absolute;
    width: 20px;
    height: 35px;
    background: rgb(253, 41, 13);
    font-size: 12px;
    text-align: center;
    color: #ffffff;
    border-bottom-right-radius: 30px;
    border-bottom-left-radius: 30px;
    letter-spacing: 1px;
    opacity: 0.8;
}

.contain-footer {
    width: 300px;
    margin: 10px auto;
}
.contain-footer p {
    width: 280px;
    font-size: 15px;
    color: rgb(172, 167, 167);
    text-align: center;
}
</style>